'use strict';

const apiUrl = "http://aliv18.data.moji.com/whapi/json/alicityweather/condition"
// 在阿里云购买墨迹天气API后，可看到appcode
const appCode = "37451b8db0b948aeace93f9a4338691f"
/**
 * token 的获取可参考：https://vkceyugu.cdn.bspapp.com/VKCEYUGU-public-doc/a922c840-b868-11ea-a30b-e311646dfaf2.pdf
 */
const token = "008d2ad9197090c5dddc76f583616606"

exports.main = async (event, context) => {

  const res = await uniCloud.httpclient.request(apiUrl, {
    method: 'POST',
    headers: {
      Authorization: "APPCODE " + appCode
    },
    data: {
      cityId: "80",
      token: token
    },
    dataType: 'json'
  })
  // console.log("城市信息：", res.data.data.city)
  console.log("天气信息：", res.data.data.condition)
  //返回数据给客户端
  return res.data.data
};
